www.gusucode.com > PHP展示型企业网站模板米拓整站源码 1.0PHP源码程序 > PHP展示型企业网站模板米拓整站源码 1.0/MetInfozs_v1.0/MetInfozs_v1.0/app/system/include/static/js/plugins/selectable.min.js

    /*!
 * remark (http://getbootstrapadmin.com/remark)
 * Copyright 2015 amazingsurge
 * Licensed under the Themeforest Standard Licenses
 */
!function(window,document,$){"use strict";var pluginName="asSelectable",Plugin=$[pluginName]=function(element,options){this.element=element,this.$element=$(element),this.options=$.extend({},Plugin.defaults,options,this.$element.data()),this.init()};Plugin.defaults={allSelector:".selectable-all",itemSelector:".selectable-item",rowSelector:"tr",rowSelectable:!1,rowActiveClass:"active",onChange:null},Plugin.prototype={constructor:Plugin,init:function(){var self=this,options=this.options;self.$element.on("change",options.allSelector,function(){var value=$(this).prop("checked");self.getItems().each(function(){var $one=$(this);$one.prop("checked",value).trigger("change",[!0]),self.selectRow($one,value)})}),self.$element.on("click",options.itemSelector,function(e){var $one=$(this),value=$one.prop("checked");self.selectRow($one,value),e.stopPropagation()}),self.$element.on("change",options.itemSelector,function(){var $all=self.$element.find(options.allSelector),$row=self.getItems(),total=$row.length,checked=self.getSelected().length;total===checked?$all.prop("checked",!0):$all.prop("checked",!1),self._trigger("change",checked),"function"==typeof options.callback&&options.callback.call(this)}),options.rowSelectable&&self.$element.on("click",options.rowSelector,function(e){if("checkbox"!==e.target.type&&"button"!==e.target.type&&"a"!==e.target.tagName.toLowerCase()&&!$(e.target).parent("div.checkbox-custom").length){var $checkbox=$(options.itemSelector,this),value=$checkbox.prop("checked");$checkbox.prop("checked",!value),self.selectRow($checkbox,!value)}})},selectRow:function(item,value){value?item.parents(this.options.rowSelector).addClass(this.options.rowActiveClass):item.parents(this.options.rowSelector).removeClass(this.options.rowActiveClass)},getItems:function(){return this.$element.find(this.options.itemSelector)},getSelected:function(){return this.getItems().filter(":checked")},_trigger:function(eventType){var method_arguments=Array.prototype.slice.call(arguments,1),data=[this].concat(method_arguments);this.$element.trigger(pluginName+"::"+eventType,data),eventType=eventType.replace(/\b\w+\b/g,function(word){return word.substring(0,1).toUpperCase()+word.substring(1)});var onFunction="on"+eventType;"function"==typeof this.options[onFunction]&&this.options[onFunction].apply(this,method_arguments)}},$.fn[pluginName]=function(options){if("string"!=typeof options)return this.each(function(){$.data(this,pluginName)||$.data(this,pluginName,new Plugin(this,options))});var method=options,method_arguments=Array.prototype.slice.call(arguments,1);if(/^\_/.test(method))return!1;if(!/^(get)/.test(method))return this.each(function(){var api=$.data(this,pluginName);api&&"function"==typeof api[method]&&api[method].apply(api,method_arguments)});var api=this.first().data(pluginName);return api&&"function"==typeof api[method]?api[method].apply(api,method_arguments):void 0}}(window,document,jQuery);